using DeviceCommons.DeviceMessages.Factories;
using DeviceCommons.Security;

namespace DeviceCommons
{
    /// <summary>
    /// AES加密模式枚举
    /// </summary>
    public enum AesMode
    {
        /// <summary>
        /// 快速模式：1000次PBKDF2迭代，启用密钥缓存，适用于性能测试
        /// </summary>
        Fast = 0,
        
        /// <summary>
        /// 安全模式：60000次PBKDF2迭代，禁用缓存，适用于生产环境
        /// </summary>
        Secure = 1
    }

    /// <summary>
    /// DeviceCommons库的配置选项
    /// </summary>
    public class DeviceCommonsOptions
    {
        /// <summary>
        /// 加密函数
        /// </summary>
        public Func<string, string>? EncryptFunc { get; set; }

        /// <summary>
        /// 解密函数
        /// </summary>
        public Func<string, string>? DecryptFunc { get; set; }

        /// <summary>
        /// 压缩函数
        /// </summary>
        public Func<byte[], byte[]>? CompressFunc { get; set; }

        /// <summary>
        /// 解压函数
        /// </summary>
        public Func<byte[], byte[]>? DecompressFunc { get; set; }

        /// <summary>
        /// 默认加密密码
        /// </summary>
        public string? DefaultEncryptionPassword { get; set; }

        /// <summary>
        /// 是否启用默认AES加密
        /// </summary>
        public bool EnableDefaultAesEncryption { get; set; } = false;
        
        /// <summary>
        /// AES加密模式（快速模式 vs 安全模式）
        /// </summary>
        public AesMode AesEncryptionMode { get; set; } = AesMode.Fast;

        /// <summary>
        /// 是否启用默认GZIP压缩
        /// </summary>
        public bool EnableDefaultGZipCompression { get; set; } = false;

        /// <summary>
        /// 自定义状态工厂注册
        /// </summary>
        public Dictionary<byte, Func<IServiceProvider, IStateFactory>> StateFactoryRegistrations { get; set; } = new();
    }
}